﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class comloginl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
       // Session["com"] = "1";
        //if (IsPostBack)
       // {
            this.Label5.Text = "";
            if (Session["com"] != null)
            {
                plogin.Visible = false;
                plcuss.Visible = true;
            }
            else
            {
                plogin.Visible = true;
                plcuss.Visible = false;
            }
        //}
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        String pcname = "";
        if (Session["com"] == null)
        {
            if (Session["vc"].Equals(txtcode.Text.Trim().ToUpper()))
            {
                ComLogin lg = new ComLogin();
                if (lg.LoginCom(txtname.Text.Trim(),MD5.EncodeMD5(txtpwd.Text.Trim())).Equals("1"))
                {
                    Session["com"] = lg.getMyID(txtname.Text.Trim(), MD5.EncodeMD5(txtpwd.Text.Trim()));
                    Session["isvip"] = lg.isVIP(Convert.ToInt32(Session["com"]));
               //     string isvip=(string)(Session["isvip"]);
                    plcuss.Visible = true;
                    plogin.Visible = false;
                }
                else
                {
                    Label5.Text = "<script>alert('登录信息错误!');window.location.href='ComDefault.aspx';</script>";
                }
            }
            else
            {

                Label5.Text = "<script>alert('验证码错误!');window.location.href='ComDefault.aspx';</script>";
            }
        }
        else
        {
            Label5.Text = "<script>alert('您已经登录！');window.location.href='ComDefault.aspx';</script>";
        }
    }
}
